package licode.unisop.auth.client.info;

import lombok.Data;

/**
 * 用户的认证信息（认证通过后生成的凭证)
 *
 * @author WR
 */
@Data
public class Credential {
    /**
     * 领域标识
     */
    private String realmId;

    /**
     * 认证的用户标识
     */
    private String userId;

    /**
     * 登录的用户账号
     */
    private String account;

    /**
     * 登录的方式
     */
    private String authType;

    /**
     * 登录的角色
     */
    private String roleCodes;

    /**
     * 登录的角色名称
     */
    private String roleNames;

    /**
     * 认证的客户标识
     */
    private String clientId;

    /**
     * 认证的终端标识
     */
    private String terminalId;

    /**
     * 认证的客户IP地址
     */
    private String userIp;

    private String userType;

    /**
     * 认证的平台标识
     */
    private String platformId;
    private String tenantId;

    private String accessToken;
    private String refreshToken;
    private long accessExpired;
    private long refreshExpired;

    public static String cacCacheId(String userId,
                                    String terminalId,
                                    String platformId) {
        return "au-" + userId + "-" + terminalId + "-" + platformId;
    }

    @Override
    public String toString() {
        return "Credential{" +
                "userId='" + userId + '\'' +
                ", clientId='" + clientId + '\'' +
                ", platformId='" + platformId + '\'' +
                ", accessToken='" + accessToken + '\'' +
                ", refreshToken='" + refreshToken + '\'' +
                ", accessExpired=" + accessExpired +
                ", refreshExpired=" + refreshExpired +
                '}';
    }
}
